home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cxl41.arc / CXLKEY.H < prev    next >
C/C++ Source or Header  |  1989-03-05  |  4KB  |  97 lines

  1.  
  2. /*
  3.    ┌──────────────────────────────────────────────────────────────────────────┐
  4.    │                                                                          │
  5.    │  CXLKEY.H - CXL (c) 1987, 1988 by Mike Smedley.                          │
  6.    │                                                                          │
  7.    │  This header file contains function prototypes and definitions for       │
  8.    │  keyboard functions.  Keyboard functions for windowing functions are     │
  9.    │  defined in CXLWIN.H                                                     │
  10.    │                                                                          │
  11.    └──────────────────────────────────────────────────────────────────────────┘
  12. */
  13.  
  14.  
  15. #if defined(__TURBOC__)                             /*  Turbo C  */
  16.     #if __STDC__
  17.         #define _Cdecl
  18.     #else
  19.         #define _Cdecl  cdecl
  20.     #endif
  21.     #define _Near
  22. #elif defined(__ZTC__)                              /*  Zortech C++  */
  23.     #define _Cdecl
  24.     #define _Near
  25. #elif defined(M_I86) && !defined(__ZTC__)           /*  Microsoft C/QuickC  */
  26.     #if !defined(NO_EXT_KEYS)
  27.         #define _Cdecl  cdecl
  28.         #define _Near   near
  29.     #else
  30.         #define _Cdecl
  31.         #define _Near
  32.     #endif
  33. #elif defined(__POWERC__)                           /*  Power C  */
  34.     #define _Cdecl
  35.     #define _Near
  36. #endif
  37.  
  38.  
  39. /*---------------------------[ Function Prototypes ]-------------------------*/
  40.  
  41. int      _Cdecl getchf(char *valid,int defchar);
  42. int      _Cdecl getns(char *str,int max);
  43. unsigned _Cdecl getxch(void);
  44. int      _Cdecl inputsf(char *str,char *fmt);
  45. int      _Cdecl setonkey(unsigned keycode,void (*func) (void),int pass);
  46. int      _Cdecl waitkey(void);
  47. int      _Cdecl waitkeyt(int duration);
  48.  
  49.  
  50. /*-----------------------[ definition of onkey record ]----------------------*/
  51.  
  52. struct _onkey_t {
  53.     struct _onkey_t *prev;              /* pointer to previous record       */
  54.     struct _onkey_t *next;              /* pointer to next record           */
  55.     unsigned int keycode;               /* Scan/ASCII code of trap key      */
  56.     void (*func) (void);                /* address of onkey function        */
  57.     int pass;                           /* pass key to caller? 0=no, 1=yes  */
  58. };
  59.                                         /* pointer to current onkey record  */
  60. extern struct _onkey_t *_Near _Cdecl _onkey;        
  61.  
  62.                                         /* pointer to procedure to call
  63.                                            while waiting for keypress   */
  64. extern void (*_Near _Cdecl _kbloop) (void);
  65.  
  66. /*-------------[ keyboard status codes returned from kbstat() ]--------------*/
  67.  
  68. #define RSHIFT      1                   /*  right shift pressed          */
  69. #define LSHIFT      2                   /*  left shift pressed           */
  70. #define CTRL        4                   /*  <Ctrl> pressed               */
  71. #define ALT         8                   /*  <Alt> pressed                */
  72. #define SCRLOCK     16                  /*  <Scroll Lock> toggled        */
  73. #define NUMLOCK     32                  /*  <Num Lock> toggled           */
  74. #define CAPSLOCK    64                  /*  <Caps Lock> toggled          */
  75. #define INS         128                 /*  <Ins> toggled                */
  76.  
  77.  
  78. /*-----------------------[ macro-function definitions ]-----------------------*/
  79.  
  80. #if !defined(MK_FP)
  81. #define MK_FP(seg,ofs)      ((void far *) (((unsigned long)(seg) << 16) | \
  82.                             (unsigned)(ofs)))
  83. #endif
  84. #if !defined(poke)
  85. #define poke(a,b,c)         (*((int  far*)MK_FP((a),(b))) = (int)(c))
  86. #define pokeb(a,b,c)        (*((char far*)MK_FP((a),(b))) = (char)(c))
  87. #define peek(a,b)           (*((int  far*)MK_FP((a),(b))))
  88. #define peekb(a,b)          (*((char far*)MK_FP((a),(b))))
  89. #endif
  90. #define capsoff()           poke(0,0x417,peek(0,0x417)&191)
  91. #define capson()            poke(0,0x417,peek(0,0x417)|64)
  92. #define clearkeys()         while(kbhit()) getch()
  93. #define kbstat()            peek(0,0x417)
  94. #define numoff()            poke(0,0x417,peek(0,0x417)&223)
  95. #define numon()             poke(0,0x417,peek(0,0x417)|32)
  96. #define setkbloop(a)        (_kbloop=a)
  97.